<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body>
<div style="height: 10px"></div>
<form class="layui-form" action="" id="pass" onsubmit="return false" style="width: 350px">
    <div class="layui-form-item">
        <label class="layui-form-label">原密码</label>
        <div class="layui-input-inline">
            <input type="password" name="pass" required lay-verify="required" placeholder="原密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-inline">
            <input type="password" name="new_pass" id="new_pass" required lay-verify="required" placeholder="新密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">必须同时包含数字，字母和特殊符号</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" id="password" required lay-verify="required" placeholder="确认密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" id="update">立即修改</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script src="__JS__/check_pass.js"></script>
<script>
    $("#update").click(function(){
        var new_pass = $("#new_pass").val();
        var password = $("#password").val();
        if(!checkPassword(new_pass)){
            return;
        }
        if(password != new_pass){
            layer.msg('两次密码不一致',{icon:5,time:2000});
            return;
        }
        $.ajax({
            url:"{:url('/admin/updatePass')}",
            data:$("#pass").serialize(),
            type:"post",
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        top.location.href = "{:url('/login/loginOut')}";
                    });
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                    return;
                }
            }
        });
    });

</script>
</html>